package com.njust;

import java.text.ParseException;
import java.util.Properties;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

import com.github.pagehelper.PageHelper;
import com.njust.properities.QixiProperties;

/**
 * Created by zhujiawei on 2017/12/28.
 */
@SpringBootApplication
@EntityScan("com.njust.dataobject")
@MapperScan("com.njust.mapper")
@EnableConfigurationProperties({QixiProperties.class})
public class QixiApplication {
    @Bean
    public PageHelper pageHelper() {
        PageHelper pageHelper = new PageHelper();
        Properties properties = new Properties();
        properties.setProperty("reasonable", "true");
        properties.setProperty("supportMethodsArguments", "true");
        properties.setProperty("returnPageInfo", "check");
        properties.setProperty("params", "count=countSql");
        //properties.setProperty("offsetAsPageNum", "true");
        properties.setProperty("rowBoundsWithCount", "true");
        properties.setProperty("dialect", "mysql");
        //配置mysql数据库的方言
        pageHelper.setProperties(properties);
        return pageHelper;
    }
    //用于从main方法启动Spring应用
    public static void main(String[] args) throws ParseException {
        SpringApplication.run(QixiApplication.class, args);

    }
}
